home *** CD-ROM | disk | FTP | other *** search
/ Java Primer Plus / Java Primer Plus (Waite Group Proess)(1996).iso / chapter11 / finaly.java < prev    next >
Text File  |  1995-12-31  |  443b  |  24 lines

  1. /* Finally example (couldn't name class "finally") */
  2. class finaly {
  3.  
  4.     public static void main(String args[]) {
  5.       System.out.println(tester(20));
  6.      }
  7.  
  8.     public static int tester(int a) {
  9.  
  10.     
  11.     try {
  12.       a = 100/a;
  13.       if (a<10) return 10;
  14.       System.out.println("Yeah! a > 9");
  15.     } catch (ArithmeticException e) {
  16.         System.out.println(e.getMessage());
  17.         }
  18.     finally {
  19.         System.out.println("Try is done");
  20.         }
  21.     return a;
  22.      }
  23.     }
  24.